{extend name="layout/index" /}

{block name="search"}
<div class="tile-title">
	<div class="tile-body">
		<form class="row" action="" >
			<div class="form-group col-md-3">
				<input class="form-control" type="text" name="title" placeholder="请输入名称" 
				value="{:input('get.title')}">
			</div>
			<div class="form-group col-md-9 align-self-end">
				<button class="btn btn-primary" type="submit">
					<i class="fa fa-fw fa-lg fa-search"></i>
					搜索
				</button>
				<a href="{:url($now_route['url'])}" class="btn btn-primary" >
					<i class="fa fa-fw fa-lg fa-dot-circle-o"></i>
					重置
				</a>
				<a href="{:url($now_route['controller'].'/excel',$getparam)}" target="_blank" class="btn btn-primary" >
					<i class="fa fa-fw fa-lg fa-download"></i>
					导出当前数据
				</a>
				{if checkurl($now_route["controller"]."/delete")}
				<button class="btn btn-primary alldelete" type="button">
					<i class="fa fa-fw fa-lg fa-trash-o"></i>
					删除
				</button>
				{/if}
			</div>
		</form>
	</div>
</div>
{/block}

{block name="table"}
<form id="delform">
<table class="table">
	<thead>
		<tr>
			<!--<th>编号</th>-->
			<th>
				<input type="checkbox" name="checkboxul" value="1" class="checkboxul">
			</th>
			<th>{$tables['fields']['title']['name']}</th>
			<th>{$tables['fields']['name']['name']}</th>
			<th>{$tables['fields']['status']['name']}</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>

	{foreach $lists as $key=>$vo } 
	<tr>
		<!--<td>{$vo.id}</td>-->
		<td>
			<input type="checkbox" name="id[]" value="{$vo.id}" class="checkboxli">
		</td>
		<td>{$vo.title}</td>
		<td>{$vo.name}</td>
		<td>{$vo.status}</td>
		<td >
			{if checkurl($now_route['controller'].'/read')}
			<a href="{:url('read',array('id'=>$vo['id']))}" title="浏览"><i class="fa fa-lg fa-fw fa-eye"></i></a>
			{/if}
			{if checkurl($now_route['controller'].'/edit')}
			<a href="{:url('edit',array('id'=>$vo['id']))}" title="修改"><i class="fa fa-lg fa-fw fa-edit"></i></a>
			{/if}
			{if checkurl($now_route['controller'].'/delete')}
			<a href="javascript:;" data-href="{:url('delete',array('id'=>$vo['id']))}" title="删除" class="delete">
				<i class="fa fa-lg fa-fw fa-trash-o"></i>
			</a>
			{/if}
		</td>
	</tr>
	{/foreach}
	<tr>
		<td colspan="5">
			{if checkurl($now_route["controller"]."/delete")}
			<button class="btn btn-primary alldelete" type="button">
			删除
			</button>
			{/if}
		</td>
	</tr>

	</tbody>
</table>
</form>
{/block}

{block name="javascript"}
<script>
	$('.delete').click(function(){
		var url = $(this).attr('data-href');
		var param = {};
		postdelete(url,param);
	});

	$('.checkboxul').click(function(){
		//alert($(".checkboxul").is(':checked'));
		//alert($(".checkboxul").is(':checked'));
		var check = $(".checkboxul").is(':checked');
		if(check){
			$('.checkboxli').prop("checked",true);
		}else{
			$('.checkboxli').prop("checked",false);
		}
	});

	$('.alldelete').click(function(){
		var url = '{:url('delete')}';
		var param = $("#delform").serialize();
		postdelete(url,param);
	});
</script>
{/block}
